package edu.gyc.hishiro.service.impl;

import edu.gyc.hishiro.dao.SysPermissionDao;
import edu.gyc.hishiro.dao.SysRoleDao;
import edu.gyc.hishiro.model.SysPermission;
import edu.gyc.hishiro.model.SysRole;
import edu.gyc.hishiro.model.UserInfo;
import edu.gyc.hishiro.dao.UserInfoDao;
import edu.gyc.hishiro.service.UserInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ls
 * @since 2021-01-04
 */
@Service
//@CacheConfig(cacheNames = "menu")
public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfo> implements UserInfoService {


    @Autowired
    SysRoleDao roleDao;

    @Autowired
    SysPermissionDao permissionDao;
    @Override
//    @Cacheable(key = "#uid")
    public Set<SysPermission> getUserMenu(Integer uid) {
        Set<SysRole> roles = roleDao.findRolesByUserId(uid);
        Set<SysPermission> permissions=null;
        if (roles.size() > 0) {
            permissions = permissionDao.findPermissionsByRoleId(roles);

        }

        return permissions;
    }
}
